package cn.t.enums.user;

import cn.t.core.enums.base.CommonEnum;
import cn.t.core.exception.BizException;
import cn.t.core.enums.base.CommonError;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author l
 */

@Getter
@AllArgsConstructor
public enum LimitedTypeEnum implements CommonEnum<Integer, String> {

    NO_LIMIT(1, "不限制"), DAILY(2, "每天"), WEEKLY(3, "每周"),
    SEMI_ANNUALLY(4, "每年"), ANNUALLY(5, "每年"), HOURLY(6, "每小时");


    @JsonValue
    @EnumValue
    private final Integer code;
    private final String name;

    public static cn.t.enums.user.PassportTypeEnum getByCode(Integer source) {
        for (cn.t.enums.user.PassportTypeEnum value : cn.t.enums.user.PassportTypeEnum.values()) {
            if (value.getCode().equals(source)) {
                return value;
            }
        }

        throw new BizException(CommonError.ILLEGAL_PARAMETER);
    }

}
